#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s1, s2;
	cin>>s1>>s2;
	s1 += s1;
	s2 += s2;
	int len1 = s1.size();
	int len2 = s2.size();
	int len = min(len1, len2)/2;
	int mx = 0;
	for(int k = 1;k <= len;k++)
	{
		for(int i = 0;i < len1;i++)
		{
			if(i+k >= len1)
				break;
			string t(s1, i, k);
			if(s2.find(t) != -1)
				mx = max(mx, k);
		}
	}
	cout<<mx;
    return 0;
}

